﻿CREATE PROCEDURE [dbo].[Sys_UserManager_CreateUser]
	@userName nvarchar(20),
	@pw varchar(50)
AS

		DECLARE @OutputTbl TABLE (ID INT)
		declare @userID int

		set @userID=-1;

		begin try
			begin tran

			INSERT INTO [sys_LoginUsers]([UserName], [Password], [GUID])
			OUTPUT INSERTED.[UserID] INTO @OutputTbl(ID)
			VALUES (@userName, @pw, CAST(NEWID() AS VARCHAR(40)))

			select @userID=id from @OutputTbl

			if @userID>0
			begin
				commit tran
			end
			else
			begin
				rollback tran
			end

		end try
		begin catch
			rollback tran
		end catch
RETURN 0
